
    $("#dl").click(function(){
        $.ajax({
            url:"http://localhost:3000/api1",
            data:{
                type:"login",
                username:$("#login").val(),
                password:$("#pass").val()
            },
       
            success:res=>{
                res = JSON.parse(res);
                console.log(res);
                if(res.code === 0){
                    alert("密码错误");
                    $("#pass").val("");
                    $("#pass")[0].focus();
                }else if(res.code === 1){
                    if(confirm("登录成功，是否跳转到首页")){
                        location.href = "../html/index.html";
                    }
                    localStorage.setItem("isLogin","OK");
                    localStorage.setItem("username",res.data);
                }else if(res.code === 2){
                    if(confirm("用户名不存在，是否跳转到注册")){
                        location.href = "./register.html?username="+$("#register").val();
                    }else{
                        $("#register").val("");
                        $("#register")[0].focus();
                    }
                }
            }
            
        })
    })

    var otxt = document.querySelector("#pass");
    otxt.onblur = function(){
        var num = 0;
        var az = 0;
        var ts = 0;
        for(var i=0;i<otxt.value.length;i++){
            if(otxt.value[i] >=0 && otxt.value[i] <= 9){
                num = 1;
            }
            if((otxt.value[i] >="a" && otxt.value[i] <= "z") || (otxt.value[i] >="A" && otxt.value[i] <= "Z")){
                az = 1;
            }
            if(!((otxt.value[i] >=0 && otxt.value[i] <= 9) || (otxt.value[i] >="a" && otxt.value[i] <= "z") || (otxt.value[i] >="A" && otxt.value[i] <= "Z"))){
                ts = 1;
            }
        }
        switch(num + az + ts){
            case 1:
                otxt.nextElementSibling.innerHTML = "差";
                break;
            case 2:
                otxt.nextElementSibling.innerHTML = "中";
                break;
            case 3:
                otxt.nextElementSibling.innerHTML = "强";
                break;
            case 4:
                otxt.nextElementSibling.innerHTML = "";
                break;
        }
    }
